<template>
  <div v-if="loading">正在加载...</div>
  <el-select
    v-else
    :value="value"
    placeholder="请选择学院"
    @change="$emit('input', $event)"
  >
    <el-option
      v-for="college in collegeList"
      :key="college.id"
      :label="college.collegeName"
      :value="college.id"
    />
  </el-select>
</template>

<script>
import { getCollegeList } from '@/api/admin/college'

export default {
  name: 'CollegeSelect',
  props: {
    value: {
      type: Number,
      default: undefined
    }
  },
  data() {
    return {
      loading: true,
      collegeList: []
    }
  },
  created() {
    this.getCollegeList()
  },
  methods: {
    /**
     * 获取学院信息
     */
    async getCollegeList() {
      this.collegeList = await getCollegeList()
      this.loading = false
    }
  }
}
</script>
